<?php

require_once( '../peachpie.php' );

// Get all form variables for insertion into database

if( getVar( 'username', 'POST' ) ) {
  $username = getVar( 'username', 'POST' );
  $password = sha1( getVar( 'password', 'POST' ) );
  $email = getVar( 'email', 'POST' );
  $admin = getVar( 'admin', 'POST' );
  if( $admin == 'on' ) {
    $admin = 1;
  } else {
    $admin = 0;
  }
  
  User::addUser( $username, $password, $email, $admin );
  $message = 'User '. $username .' has been added!';
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
  <title>PeachPie CMS</title>
  <link rel="stylesheet" type="text/css" href="../include/style.css" />
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <meta name="robots" content="none" />
  <script type="text/javascript" src="../include/javascript.js"></script>
</head>

<body>

  <div class="wrapper">

    <div class="header" id="nav">
      <ul>
        <li><a href="$siteurl/home.php" rel="self">Home</a></li>
        <li><a href="$siteurl/blog.php" rel="self">Blog</a></li>
        <li><a href="$siteurl/photos.php" rel="self">Photos</a></li>
        <li><a href="$siteurl/admin.php" rel="self">Admin</a></li>
      </ul>
    </div>

    <div class="logo">
      <div class="inner"></div>
    </div>

    <div class="content">
      <div class="form">
        <form method="post" action="">
          <div class="left">
            <div><label for="username">Username : </label></div>
            <div><label for="password">Password : </label></div>
            <div><label for="email">Email : </label></div>
            <div><label for="admin">Admin?</label></div>
          </div>
          <div class="right">
            <div><input type="text" name="username" value="" maxlength="16" /></div>
            <div><input type="text" name="password" value="" maxlength="16" /></div>
            <div><input type="text" name="email" value="" /></div>
            <div><input type="checkbox" name="admin" /></div>
          </div>
          
          <div class="reset"></div>
          <div class="submit"><input type="submit" name="submit"  value="submit" class="submit" /></div>
        </form>
      </div>
      <div class="reset"></div>
    </div>

    <div class="footer">
      PeachPie Content Management System &copy; 2006<br />
      PeachPie is licensed under the GPLv3, is redistributable, and pieces of PeachPie 
      may be used in other software products.
    </div>

</body>
</html>